﻿<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://cesium.marsgis.cn ">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="x5-fullscreen" content="true">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta name="description"
        content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS" />

    <link rel="shortcut icon" type="image/x-icon" href="http://cesium.marsgis.cn/favicon.ico">
    <title>三维地图 |Mars3D ( MarsGIS for Cesium )|三维地图| 火星科技|合肥火星科技|合肥火星科技有限公司</title>


    <!--第三方lib-->
    <script type="text/javascript" src="../lib/include-lib.js" libpath="../lib/"
        include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"></script>

    <link href="css/style.css" rel="stylesheet" />
</head>

<body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="cesiumContainer" class="mars3d-container"></div>


    <!-- 面板 -->
    <div class="infoview">
        1、我们对Cesium本身的事件做了简化处理。<br />
        2、可以直接在entity或primitive构造时绑定回调方法进行处理。<br />
        3、目前支持绑定click 单击、mouseover 鼠标移入、mouseout 鼠标移出 。<br />
        另：框架的popup、tooltip也是基于此类似规则绑定的。<br />

    </div>



    <!-- 涉及mars的在线服务地址统一配置入口 -->
    <script type="text/javascript" src="config/marsUrl.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {
            if (!mars3d.util.webglreport()) {
                alert('系统检测到您使用的浏览器不支持WebGL功能');
                layer.open({
                    type: 1,
                    title: "当前浏览器不支持WebGL功能",
                    closeBtn: 0,
                    shadeClose: false,
                    resize: false,
                    area: ['600px', '200px'], //宽高
                    content: '<div style="margin: 20px;"><h3>系统检测到您使用的浏览器不支持WebGL功能！</h3>  <p>1、请您检查浏览器版本，安装使用最新版chrome、火狐或IE11以上浏览器！</p> <p>2、WebGL支持取决于GPU支持，请保证客户端电脑已安装显卡驱动程序！</p></div>'
                });
            }

            initMap();
        });

        function removeMask() {
            $("#mask").remove();
        }


        var viewer;
        //初始化地图
        function initMap() {
            //url传参，一个系统动态使用不同配置
            var configfile = haoutil.system.getRequestByName("config", "config/config.json");

            mars3d.createMap({
                id: 'cesiumContainer',
                url: configfile,
                center: { "y": 31.808241, "x": 117.224601, "z": 4071.32, "heading": 356.7, "pitch": -61, "roll": 360 },
                success: function (_viewer, jsondata) {//地图成功加载完成后执行
                    viewer = _viewer;

                    setTimeout(removeMask, 3000);
                    initWork();
                }
            });
        }


        //当前页面业务相关
        function initWork() {
            //单击地图空白（未单击到矢量或模型数据）时
            viewer.mars.on(mars3d.event.clickMap, function (event) {
                haoutil.msg('单击了地图空白处');
            });

            var pointEntity = viewer.entities.add({
                name: "点",
                position: Cesium.Cartesian3.fromDegrees(117.22193, 31.823638, 43.48),
                billboard: {
                    image: 'img/marker/mark3.png',
                    scale: 1,
                    horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                    verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                    heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                },
                click: function (entity) {//单击
                    haoutil.alert('你单击了billboard：' + entity._name);

                },
                mouseover: function (entity) {//移入
                    haoutil.msg('你鼠标移入到billboard：' + entity._name);

                },
                mouseout: function (entity) {//移出
                    haoutil.msg('你鼠标移出了billboard：' + entity._name);

                },
            });

            var lineEntity = viewer.entities.add({
                name: "线",
                polyline: {
                    positions: Cesium.Cartesian3.fromDegreesArrayHeights([
                        117.210308, 31.82165, 39.61,
                        117.217186, 31.819723, 35,
                        117.216931, 31.828351, 38.79,
                        117.214205, 31.828521, 41.01,
                        117.214378, 31.825595, 32.42
                    ]),
                    width: 7,
                    material: Cesium.Color.YELLOW.withAlpha(0.5),
                    clampToGround: true
                },
                click: function (entity) {//单击
                    haoutil.alert('你单击了polyline：' + entity._name);

                },
                mouseover: function (entity) {//移入
                    haoutil.msg('你鼠标移入到polyline：' + entity._name);

                },
                mouseout: function (entity) {//移出
                    haoutil.msg('你鼠标移出了polyline：' + entity._name);

                },
            });


            var polyEntity = viewer.entities.add({
                name: "面",
                polygon: {
                    hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights([
                        117.220448, 31.834688, 40.72,
                        117.226041, 31.834192, 40.93,
                        117.226094, 31.831935, 48.08,
                        117.220457, 31.831917, 46.88,
                        117.220448, 31.834688, 40.72
                    ])),
                    width: 5,
                    material: Cesium.Color.YELLOW.withAlpha(0.3),
                    classificationType: Cesium.ClassificationType.BOTH
                },
                click: function (entity) {//单击
                    haoutil.alert('你单击了polygon：' + entity._name);

                },
                mouseover: function (entity) {//移入
                    haoutil.msg('你鼠标移入到polygon：' + entity._name);

                    highlightedEntity(entity, 1)
                },
                mouseout: function (entity) {//移出
                    haoutil.msg('你鼠标移出了polygon：' + entity._name);

                    highlightedEntity(entity, 0.3)
                },
            });



            mars3d.layer.createLayer(viewer, {
                "name": "教学楼",
                "type": "3dtiles",
                "url": serverURL_3dtiles + "/bim-daxue/tileset.json", //定义在 config\marsUrl.js 
                "scale": 3,
                "offset": { "x": 117.228508, "y": 31.82915, "z": 53, "heading": 1.9 },
                "maximumScreenSpaceError": 16,
                "maximumMemoryUsage": 1024,
                "scenetree": "scenetree.json",
                "showClickFeature": true,
                // "popup": "all", 
                "visible": true,
                click: function (entity) {//单击                
                    haoutil.alert('你单击了3dtiles：' + entity.attr.sid);
                },
                // mouseover: function (entity) {//移入
                //     
                //     haoutil.msg('你鼠标移入到3dtiles：' + entity.attr.name); 
                // },
                // mouseout: function (entity) {//移出
                //     haoutil.msg('你鼠标移出了3dtiles：' + entity.attr.name); 
                // },
            });



            //示例popup和tooltip
            var pointEntity = viewer.entities.add({
                name: "示例点",
                position: Cesium.Cartesian3.fromDegrees(117.23593, 31.824638, 43.48),
                billboard: {
                    image: 'img/marker/mark1.png',
                    scale: 1,
                    horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                    verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                    heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                },
                label: {
                    text: "popup和tooltip示例",
                    font: 'normal small-caps normal 19px 楷体',
                    style: Cesium.LabelStyle.FILL_AND_OUTLINE,
                    fillColor: Cesium.Color.AZURE,
                    outlineColor: Cesium.Color.BLACK,
                    outlineWidth: 2,
                    horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                    verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                    pixelOffset: new Cesium.Cartesian2(0, -50),   //偏移量   
                },
                tooltip: "<span style='color:#ffffff;'>测试的tooltip</span>",
                popup: "<span style='color:red;'>测试的popup</span>",
            });

        }

        //高亮面
        function highlightedEntity(entity, alpha) {
            var color = entity.polygon.material.color;
            var newclr = color.getValue().withAlpha(alpha);
            color.setValue(newclr);
        }



    </script>
</body>

</html>